﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CharacterFactory
{
    public partial class ViewSpriteFile : Form
    {
        public ViewSpriteFile()
        {
            InitializeComponent();
        }

        public List<Bitmap> spriteFiles = new List<Bitmap>();

        public void viewSprite(int id)
        {
            try
            {
                if (spriteFiles[id].Width > pictureBox1.Width || spriteFiles[id].Height > pictureBox1.Height)
                {
                    ImageProcessing imp = new ImageProcessing();
                    pictureBox1.Image = imp.ResizeBitmap(spriteFiles[id], pictureBox1.Width, pictureBox1.Height) ;
                }
                else
                {
                    pictureBox1.Image = spriteFiles[id];
                }
                
            }
            catch (Exception xcp)
            {
                MessageBox.Show(xcp.ToString());
            }
        }

        public void initScroll(int n)
        {
            hScrollBar1.Maximum = n - 1;
        }

        private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {
            try
            {
                viewSprite(hScrollBar1.Value);
            } 
            catch(Exception xcp)
            {
                MessageBox.Show(xcp.ToString());
            }
        }

    }
}
